package com.group.mall.mapper;

import com.group.mall.domain.DTO.UserDTO;
import com.group.mall.domain.POJO.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface UserMapper {

    Boolean addUser(User user);

    @Select("select * from hmall.user where id = #{id}")
    List<User> getUser(Long id);

    @Select("select * from hmall.user where username = #{username} ")
    List<User> getUsername(String username);

    @Update("update hmall.user set username = #{username},password = #{password}, phone = #{phone}, sex = #{sex},icon = #{icon} where id = #{id}")
    void updateUser(UserDTO userDTO);

    @Select("select  * from  hmall.user where id = #{id}")
    List<User> getBalance(Long id);

    @Update("update hmall.user set balance = balance + #{balance} where id = #{id}")
    void updateRecharge(User user);

    User getUserList(Integer userId);
}
